package com.my.financial.controller;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;


public class MainTest {
	
	public static void main(String[] args) {
		new Thread(new Thread1()).start();
		new Thread(new Thread2()).start();
	}
}

class Thread1 implements Runnable{

	@Override
	public void run() {
		try {
			for(int i=0;i<500;i++){
				URL u = new URL("http://localhost:8080/createItem?type=支出&item=蔬菜水果&userId=1&amount=100");
				HttpURLConnection uConnection = (HttpURLConnection)u.openConnection();
				uConnection.connect();
				System.out.println(uConnection.getResponseCode());
				System.out.println("t1");
			}
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

class Thread2 implements Runnable{

	@Override
	public void run() {
		try {
			for(int i=0;i<500;i++){
			URL u = new URL("http://localhost:8080/createItem?type=收入&item=充值&userId=1&amount=110");
			HttpURLConnection uConnection = (HttpURLConnection)u.openConnection();
			uConnection.connect(); 
			System.out.println(uConnection.getResponseCode());
			System.out.println("t2");
			}
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}